#include "Location.h"
#include <iostream>
#include <math.h>

Location::Location()
{
	x = y = z = 0.0f;
}

Location::Location(float xv, float yv, float zv) : x(xv), y(yv), z(zv)	{

}

Location::~Location() {
	// std::cout << "Deleting Location\n";
}

Location::Location(const Location& loc) {
	x = loc.x;
	y = loc.y;
	z = loc.z;
}

Location& Location::operator=(const Location& loc) {
	x = loc.x;
	y = loc.y;
	z = loc.z;
	return *this;
}

float Location::getVal(int axis) {
	if (axis == 0) return x;
	if (axis == 1) return y;
	return z;
}

float Location::distance(const Location& loc) {
	float xD = x - loc.x;
	float yD = y - loc.y;
	float zD = z - loc.z;
	return sqrt((xD*xD)+(yD*yD)+(zD*zD));
}


void Location::set(const Location& loc) {
	x = loc.x;
	y = loc.y;
	z = loc.z;
}

void Location::set(float dx, float dy, float dz)
{
	x = dx;
	y = dy;
	z = dz;
}

void Location::set(int axis, float val)
{
	if (axis == 0) { x = val; }
	else if (axis == 1) { y = val; }
	else { z = val; }
}

void Location::setX(float dx)
{
	x = dx;
}

void Location::setY(float dy)
{
	y = dy;
}

void Location::setZ(float dz)
{
	z = dz;
}